package com.thread.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author milian
 * @Date 2021/7/30 0030 9:19
 */
public class demo2 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(2);
        ThreadPoolExecutor poolExecutor  =(ThreadPoolExecutor) executorService;
        System.out.println(poolExecutor.getPoolSize());
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName());
        });
        System.out.println(poolExecutor.getPoolSize());
        executorService.shutdown();
    }
}
